<template>
  <el-tooltip :content="$i18n.t('mind.copyMsg')" v-model="copySuccess" placement="right" manual>
    <span @dblclick="copy">{{ text }}</span>
  </el-tooltip>
</template>

<script>
export default {
  name: 'LabelCopy', // 标题复制
  props: {
    text: {
      type: [String, Number],
      default: ''
    }
  },
  data() {
    return {
      copySuccess: false
    }
  },
  methods: {
    copy() {
      let cInput = document.createElement('input')
      cInput.value = this.text
      document.body.appendChild(cInput)
      cInput.select()
      document.execCommand('copy')
      this.copySuccess = true
      setTimeout(() => {
        this.copySuccess = false
      }, 1000)
      document.body.removeChild(cInput)
    }
  }
}
</script>

<style lang="scss" scoped></style>
